uniform float tilingFactor;

uniform float waterLevel;
uniform float counter;

varying vec4 normal;

void main()
{
    normal.xyz = normalize(gl_NormalMatrix * gl_Normal);
    normal.w = gl_Vertex.y - waterLevel;

	vec4 vertex = gl_Vertex;

	if(normal.w <= waterLevel)
		vertex.y -= cos(counter + vertex.x + vertex.z);

    gl_Position = gl_ModelViewProjectionMatrix * vertex;
    gl_TexCoord[0] = gl_MultiTexCoord0 * tilingFactor;
}
